class SpecialDeduction {
  final String title;
  final String topBgImage;
  final List<DeductionSection> sections;
  final List<String> notes;
  final List<DeductionQuestion> questions;

  SpecialDeduction({
    required this.title,
    required this.topBgImage,
    required this.sections,
    required this.notes,
    required this.questions,
  });

  factory SpecialDeduction.fromJson(Map<String, dynamic> json) {
    return SpecialDeduction(
      title: json['title'] ?? '',
      topBgImage: json['topBgImage'] ?? '',
      sections: (json['sections'] as List<dynamic>?)
              ?.map((e) => DeductionSection.fromJson(e as Map<String, dynamic>))
              .toList() ??
          [],
      notes: (json['notes'] as List<dynamic>?)?.cast<String>() ?? [],
      questions: (json['questions'] as List<dynamic>?)
              ?.map((e) => DeductionQuestion.fromJson(e as Map<String, dynamic>))
              .toList() ??
          [],
    );
  }
}

class DeductionSection {
  final String sectionTitle;
  final String sectionBgImage;
  final List<String> items;

  DeductionSection({
    required this.sectionTitle,
    required this.sectionBgImage,
    required this.items,
  });

  factory DeductionSection.fromJson(Map<String, dynamic> json) {
    return DeductionSection(
      sectionTitle: json['sectionTitle'] ?? '',
      sectionBgImage: json['sectionBgImage'] ?? '',
      items: (json['items'] as List<dynamic>?)?.cast<String>() ?? [],
    );
  }
}

class DeductionQuestion {
  final String question;
  final String answer;

  DeductionQuestion({
    required this.question,
    required this.answer,
  });

  factory DeductionQuestion.fromJson(Map<String, dynamic> json) {
    return DeductionQuestion(
      question: json['Q'] ?? '',
      answer: json['A'] ?? '',
    );
  }
}